package com.pug.security.po;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author feige
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@TableName("pug_user")
public class SysUser  implements UserDetails, Serializable {

    private static final long serialVersionUID = 1L;
    @TableId(type = IdType.AUTO)
    private Long id;
    //用户名
    private String username;
    //密码
    private String password;
    //手机
    private String phone;
    //邮箱
    private String email;
    //创建时间
    @TableField(fill = FieldFill.INSERT)
    private Date created;
    //更新时间
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updated;

    @TableField(exist = false)
    private List<SysPermission> permissions;
    @TableField(exist = false)
    private List<SysRole> roles;
    // 验证授权相关信息
    @TableField(exist = false)
    private  List<GrantedAuthority> authorities;
    @TableField(exist = false)
    private  boolean accountNonExpired = true;
    @TableField(exist = false)
    private  boolean accountNonLocked = true;
    @TableField(exist = false)
    private  boolean credentialsNonExpired = true;
    @TableField(exist = false)
    private  boolean enabled = true;

}
